package com.fansaikj.crm.domain;

import lombok.Data;
import xyz.erupt.annotation.*;
import xyz.erupt.annotation.sub_erupt.*;
import xyz.erupt.annotation.sub_field.*;
import xyz.erupt.annotation.sub_field.sub_edit.*;
import xyz.erupt.upms.handler.DictChoiceFetchHandler;
import xyz.erupt.upms.model.base.HyperModel;
import xyz.erupt.jpa.model.BaseModel;
import java.util.*;
import java.util.Date;
import javax.persistence.*;
import org.hibernate.annotations.GenericGenerator;

@Erupt(
    name = "客户表",
    power = @Power(importable = true, export = true)
)
@Table(name = "crm_customer")   //数据库表名
@Entity
@Data
public class CrmCustomer {


    @Id
    @GeneratedValue(generator="generator")
    @GenericGenerator(name="generator", strategy="native")
    @Column(nullable = false)
    @EruptField()
    private Long id;
    
    @Column(length = 100, nullable = false)
    @EruptField(
        views = @View(
            title = "客户名称",
            width = "120"
        ),
        edit = @Edit(
            title = "客户名称",
            notNull = true,
            search = @Search(vague = true)
        )
    )
    private String customerName;
    
    @Column(length = 20)
    @EruptField(
        views = @View(
            title = "客户类型",
            desc = "客户类型（企业/个人）",
            width = "120"
        ),
        edit = @Edit(
            title = "客户类型",
            desc = "客户类型（企业/个人）",
            type = EditType.CHOICE,
            choiceType = @ChoiceType(
                fetchHandler = DictChoiceFetchHandler.class,
                fetchHandlerParams = { "dic_customer_type", "5000" }
            ),
            search = @Search
        )
    )
    private String customerType;
    
    @Column(length = 50)
    @EruptField(
        views = @View(
            title = "客户来源",
            width = "120"
        ),
        edit = @Edit(
            title = "客户来源",
            search = @Search
        )
    )
    private String customerSource;
    
    @Column(length = 20, nullable = false)
    @EruptField(
        views = @View(
            title = "客户状态",
            width = "120"
        ),
        edit = @Edit(
            title = "客户状态",
            notNull = true,
            search = @Search
        )
    )
    private String customerStatus;
    
    @Column(length = 50)
    @EruptField(
        views = @View(
            title = "所属行业",
            width = "120"
        ),
        edit = @Edit(
            title = "所属行业"
        )
    )
    private String industry;
    
    @Column(length = 200)
    @EruptField(
        views = @View(
            title = "地址",
            width = "120"
        ),
        edit = @Edit(
            title = "地址"
        )
    )
    private String address;
    
    @Column(length = 100)
    @EruptField(
        views = @View(
            title = "官网",
            width = "120"
        ),
        edit = @Edit(
            title = "官网"
        )
    )
    private String website;
    
    @Column(length = 50, nullable = false)
    @EruptField(
        views = @View(
            title = "创建人",
            width = "120"
        ),
        edit = @Edit(
            title = "创建人",
            notNull = true
        )
    )
    private String createBy;
    
    @Column(nullable = false)
    @EruptField(
        views = @View(
            title = "创建时间",
            width = "120"
        ),
        edit = @Edit(
            title = "创建时间",
            notNull = true,
            type = EditType.DATE,
            dateType = @DateType(type = DateType.Type.DATE)
        )
    )
    private Date createTime;
    
    @Column(length = 50)
    @EruptField(
        views = @View(
            title = "修改人",
            width = "120"
        ),
        edit = @Edit(
            title = "修改人"
        )
    )
    private String updateBy;
    
    @EruptField(
        views = @View(
            title = "修改时间",
            width = "120"
        ),
        edit = @Edit(
            title = "修改时间",
            type = EditType.DATE,
            dateType = @DateType(type = DateType.Type.DATE)
        )
    )
    private Date updateTime;
    
    @Column(length = 255)
    @EruptField(
        views = @View(
            title = "备注",
            width = "120"
        ),
        edit = @Edit(
            title = "备注"
        )
    )
    private String remark;
    
    /*
    @OneToMany(cascade=CascadeType.ALL)
    @JoinColumn(name = "customer_id")
    @EruptField(
        edit = @Edit(title = "联系人表列表", type = EditType.TAB_TABLE_ADD)
    )
    private Set<CrmContact> crmContactList;
    */
    
    /*
    @OneToMany(cascade=CascadeType.ALL)
    @JoinColumn(name = "customer_id")
    @EruptField(
        edit = @Edit(title = "合同表列表", type = EditType.TAB_TABLE_ADD)
    )
    private Set<CrmContract> crmContractList;
    */
    
    /*
    @OneToMany(cascade=CascadeType.ALL)
    @JoinColumn(name = "customer_id")
    @EruptField(
        edit = @Edit(title = "财务信息表列表", type = EditType.TAB_TABLE_ADD)
    )
    private Set<CrmFinance> crmFinanceList;
    */
    
    /*
    @OneToMany(cascade=CascadeType.ALL)
    @JoinColumn(name = "customer_id")
    @EruptField(
        edit = @Edit(title = "客户跟进表列表", type = EditType.TAB_TABLE_ADD)
    )
    private Set<CrmFollow> crmFollowList;
    */
    
    /*
    @OneToMany(cascade=CascadeType.ALL)
    @JoinColumn(name = "customer_id")
    @EruptField(
        edit = @Edit(title = "开票申请表列表", type = EditType.TAB_TABLE_ADD)
    )
    private Set<CrmInvoiceApply> crmInvoiceApplyList;
    */
    
    /*
    @OneToMany(cascade=CascadeType.ALL)
    @JoinColumn(name = "customer_id")
    @EruptField(
        edit = @Edit(title = "商机表列表", type = EditType.TAB_TABLE_ADD)
    )
    private Set<CrmOpportunity> crmOpportunityList;
    */
    
    /*
    @OneToMany(cascade=CascadeType.ALL)
    @JoinColumn(name = "customer_id")
    @EruptField(
        edit = @Edit(title = "产品报价表列表", type = EditType.TAB_TABLE_ADD)
    )
    private Set<CrmQuotation> crmQuotationList;
    */
    

}
